package com.gosophia.roleManagement.action;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.OrderCondition;
import com.gosophia.commons.Page;
import com.gosophia.commons.PropertyFilter;
import com.gosophia.commons.web.action.BaseAjaxAction;
import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.commons.web.bean.RequestResult;
import com.gosophia.userManagement.dto.RoleDTO;
import com.gosophia.userManagement.ws.UserManagementWebService;
import com.opensymphony.xwork2.ActionSupport;

@Scope("prototype")
@Controller("GetPageRoleAction")
public class GetPageRoleAction extends BaseSupportAction{

    
    /** 模糊查询条件*/
    private String searchString="";

    /** 排序条件*/
    private List<OrderCondition> orderConditions = new ArrayList<OrderCondition>();
    
    private Page<RoleDTO> page = new Page<RoleDTO>();
    
    
	@Autowired
	private UserManagementWebService userManagementWebService;

	@Override
	public String _execute() throws Exception {
		if(orderConditions.size() == 0){
			OrderCondition ordercondition = new OrderCondition("roleName", true);
			orderConditions.add(ordercondition);
		}
		page = userManagementWebService.findRoleByPage(page.getPageNo(), page.getPageSize(), searchString, orderConditions);
		if(page.getResult().size() == 0){
			super.getRequestResult().setRsltCode("1");
		}else{
			super.getRequestResult().setRsltCode("0");
		}
		return SUCCESS;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setOrderConditions(List<OrderCondition> orderConditions) {
		this.orderConditions = orderConditions;
	}

	public List<OrderCondition> getOrderConditions() {
		return orderConditions;
	}

	public void setPage(Page<RoleDTO> page) {
		this.page = page;
	}

	public Page<RoleDTO> getPage() {
		return page;
	}


	

	
}
